package com.github.zuihou.authority.service.common.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.zuihou.authority.dao.common.AreaMapper;
import com.github.zuihou.authority.dto.common.AreaListTreeDTO;
import com.github.zuihou.authority.dto.common.AreaQueryDTO;
import com.github.zuihou.authority.entity.auth.Role;
import com.github.zuihou.authority.entity.common.Area;
import com.github.zuihou.authority.service.common.AreaService;

import com.github.zuihou.database.mybatis.conditions.Wraps;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 业务实现类
 * 地区表
 * </p>
 *
 * @author zuihou
 * @date 2019-07-02
 */
@Slf4j
@Service
public class AreaServiceImpl extends ServiceImpl<AreaMapper, Area> implements AreaService {

    @Override
    public List<AreaListTreeDTO> pageByParentCode(IPage<AreaListTreeDTO> page, AreaQueryDTO areaQueryDTO) {
        return this.baseMapper.pageByParentCode(page, areaQueryDTO);
    }


    @Override
    public Boolean check(String code) {
        return super.count(Wraps.<Area>lbQ().eq(Area::getCode, code)) > 0;
    }
}
